package com.zhongwang.business.module.basic.service;


import com.zhongwang.business.constant.Constant;
import com.zhongwang.business.module.basic.dao.DictDao;
import com.zhongwang.business.module.basic.dao.VerifyDao;
import com.zhongwang.business.module.basic.model.DictEnumModel;
import com.zhongwang.business.module.basic.model.VerifyInfoModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static com.zhongwang.business.constant.Constant.STATUS_NORMAL;


@Service
public class VerifyBasicService {

    @Autowired
    private DictDao dictDao;
    @Autowired
    private VerifyDao verifyDao;


    /**
     * 修改部门
     */
    public int updateDict(DictEnumModel dict) {
        dict.setStatus(STATUS_NORMAL);
        return dictDao.update(dict);
    }

    /**
     * 保存
     *
     * @param
     * @return
     */
    public int saveDict(DictEnumModel dict) {
        dict.setStatus(STATUS_NORMAL);
        dict.setCreateTime(new Date());
        return dictDao.save(dict);
    }

    /**
     * 删除
     */
    public int delDict(Integer id) {
        return dictDao.updateStatusById(id, Constant.STATUS_DELETE);
    }

    /**
     * 校验 重复
     *
     * @param groupName
     * @return
     */
    public List<DictEnumModel> findDictByGroupName(String groupName) {
        return dictDao.findByGroupName(groupName);
    }

    /**
     * 条件查询列表
     */
    public List<VerifyInfoModel> findByCondition(VerifyInfoModel verify) {
        return verifyDao.findByCondition(verify);
    }


    public List<VerifyInfoModel> selectTypes() {
        List<VerifyInfoModel> list = verifyDao.selectTypes();
        return list;
    }

    public List<VerifyInfoModel> selectLevel() {
        List<VerifyInfoModel> list = verifyDao.selectLevel();
        return list;
    }

    /** 保存 */
    public int saveVerify(VerifyInfoModel verify) {
        return verifyDao.save(verify);
    }

    public int updateVerify(VerifyInfoModel verify) {
        return verifyDao.update(verify);
    }
}
